各位邦友,小編(Orz),總算把Packer跟Ansible初步介紹完了,大家可以再看一下之前提到的範例:
現在要把Packer範例中的Provisioners中加上Ansible Provisioner
Sample.json片斷:
"provisioners": [
{
"type": "ansible",
"playbook_file": "./playbook.yml"
}
]
playbook.yml:跟之前的範例有「差別」哦
---
- name: Ansible Provisioner in Packer
hosts:
- 127.0.0.1
tasks:
- name: test connection
ping:
- name: echo hello
shell: /bin/echo hello
- name: sudo apt-get install redis-server
# become: true
apt:
name: redis-server
state: present
ps:become:true
被註解掉了,因為不註解掉的話,就會一直出現"sudo: a password is required"
的錯誤不知是否是因為我本機(ubuntu)的user > bright 跟AWS EC2(ubuntu)的user > ubuntu,有什麼「差別」(目前還不太了@@),有大大可以解惑嗎?
執行packer:packer build sample.json
總算組合起來了 Orz~~
待續...快不行了@@